$(function(){
		
	head();	
	
	//取地址
	var userId = sessionStorage.getItem("userId");
					$.ajax({
							type:"POST",
							url:"http://www.youyiku-yishu.cn/WebApp/AppOrders/getDefaultAddress",
							data:{userId:userId},
						    dataType:"json",
							beforeSend: function (XMLHttpRequest) {
							XMLHttpRequest.setRequestHeader("DEVICEINFO", "JxRaZezavm3HXM3d9pWnYiqqQC1SJbsU");
													       }
							}).then(data=>{
							 var address=data.address;
							 if(address !=null){
									 	$.ajax({
											type:"POST",
											url:"http://www.youyiku-yishu.cn/WebApp/AppOrders/getDefaultAddress",
											data:{userId:userId},
										    dataType:"json",
											beforeSend: function (XMLHttpRequest) {
											XMLHttpRequest.setRequestHeader("DEVICEINFO", "JxRaZezavm3HXM3d9pWnYiqqQC1SJbsU");
																	       }
											}).then(data=>{
												var address=data.address;
												var areaId1=address.areaId1;
												var areaId2=address.areaId2;
												var areaId3=address.areaId3;
												$('#areaId1').val(areaId1);
												$('#areaId2').val(areaId2);
												$('#areaId3').val(areaId3);
												page='';	
												page+='<div class="have_div">'
												page+='收货人；';
												page+='<span class="name">'+address.addressee+'</span><br />';
												page+='电话；';
												page+='<span class="phone">'+address.phone+'</span>';
											    page+='</div>';
											    page+='<div class="have_div1">';
												page+='收货地址；';
												page+='<span  class="code1">'+address.province+'</span>';
												page+='<span  class="code2">'+address.city+'</span>';
												page+='<span  class="code3">'+address.district+'</span>';
												page+='<span  class="address">'+address.address+'</span>';
											    page+='</div>';
											    $('.have_1').html(page);
								 			})
								}else{
									$('.nothave').css('display','block');
									$('.have').css('display','none');
								}
				});
});
//选择纸张的大小
function paper(data){
			var data=data;
			console.log(data);
			if(data==0){
			$('.imgn1').css('display','none');
				$('.imgn0').css('display','inline-block');
		   	   $('#paper').val(1);
		   	   $('#real').val(3.20);
		   	   $('.CupCake').text('默认：A5文艺纸');
			}else if(data==1){
				$('.imgn'+data).css('display','none');
		   	   $('#paper').val(3);
		   	   $('.imgn0').css('display','none');
				$('.imgn1').css('display','inline-block');
				 $('#real').val(5.80);
				 $('.CupCake').text('A4文艺纸');
			}
			 realMoney();
			
}
//确定选择纸张
function radio_no(){
	$('.radio').css('display','none');
}
function numberTop(){
	$('.radio').css('display','block');
	$('.size').css('display','none');
	$('.logistics').css('display','none');
}
//书籍装帧选择
function bookbinding(data){
	var data=data;
	var paper=$('#paper').val();
			if(data==0){
				$('.imgn_1').css('display','none');
				$('.imgn_0').css('display','inline-block');				
		   	    $('#bookbinding').val(1);
		   	    $('.skin').text('默认：软皮经济装');
		   	    //A5封面的价格
		   	    if(paper==1){
					$('#aFourMoney').val(8);
				}else if(paper==3){
					$('#aFourMoney').val(18);
				}
			}else if(data==1){
				$('.imgn_0').css('display','none');
				$('.imgn_1').css('display','inline-block');
		   	   $('#bookbinding').val(2);
		   	    $('.skin').text('硬皮精装');
		   	   //A4封面的价格
		   	   if(paper==1){
					$('#aFourMoney').val(18);
				}else if(paper==3){
					$('#aFourMoney').val(28);
				}
			}
			 realMoney();
}
//确定装帧方式
function numberTop1(){
	$('.size').css('display','block')
	$('.radio').css('display','none');
	$('.logistics').css('display','none');
}
function radio_no1(){
	$('.size').css('display','none');
}
//物流选择
function logistics(data){
	var data=data;
			console.log(data);
			if(data==0){
				$('.delivery_img1').css('display','none');
				$('.delivery_img0').css('display','inline-block');
				$('#kd').val(0);
		   	   $('#wuliuType').val(21);
		   	   $('.expressage').text('默认：韵达 免邮');
			}else if(data==1){
				$('.delivery_img0').css('display','none');
				$('.delivery_img1').css('display','inline-block');
				$('#kd').val(12);
		   	   $('#wuliuType').val(12);
		   	    $('.expressage').text('默认：顺丰 加收12');
			}
			 realMoney();
}
//确定快递类型
function numberTop2(){
	$('.logistics').css('display','block');
		$('.radio').css('display','none');
	$('.size').css('display','none');
}
function radio_no2(){
	$('.logistics').css('display','none');
}
//买家留言
function comments(){
	$('.logistics').css('display','none');
		$('.radio').css('display','none');
	$('.size').css('display','none');
}
function computeWeight(){
			var weight=1;
			var page=Number($('#bookPage').text());
			var type=Number($('#paperType').val());
			var goodsNums=Number($('#goodscount').val());
			var qq=0;
			if(type==4){
				if(page*goodsNums>80){
					qq=Math.ceil((page*goodsNums-80)/80);
					weight=1000+1000*qq;
				}else{
					weight=1000;
				}
			}else if(type==5){
				if(page*goodsNums>160){
					qq=Math.ceil((page*goodsNums-160)/160);
					weight=1000+1000*qq;
				}else{
					weight=1000;
				}
			}
			return weight;
		}
		//修改商品购买数量
		function changeBookNum(flag){
			
			var num = $("#goodscount").val();
			var num = parseInt(num,10);
			console.log(num);
			var num = num?num:1;
			if(flag==1){
				if(num>1)num = num-1;
			}else if(flag==2){
				num = num+1;
			}
			var maxVal = parseInt($("#goodscount").attr('maxVal'),10);
			if(maxVal<=num)num=maxVal;
			$("#goodscount").val(num);
			$('.quantity').text(num);

			var weight=computeWeight();
			if($('.cur').length>0){
				var kd=Number($('.cur').attr('data-price'));
				var add=Number($('.cur').attr('data-add'));
				var money=0;

				if(weight>1000){
					money=kd+((weight/1000)-1)*add;
				}else{
					money=kd;
				}
				$('#kd').text(money.toFixed(2))
			}

			realMoney();
		}


		//计算价格
		function countMoney(){
//			var page=Number($('#bookPage').text());
			var page=Number($('#bookPage').html());
			conspe.log(page);
			var type=Number($('#paperType').val());
			var multiple=Number($('#multiple').val());
			var aFourMoney=Number($('#aFourMoney').val());
			var aFiveMoney=Number($('#aFiveMoney').val());
			var goodsNums=Number($('#goodscount').val())
			var total=0;
			var bookbinding=0;
			var Volumes=Math.ceil(page/220);
			var pages=Math.ceil(page);
			var relation = Number($('#relation').val())
			// console.log(type,aFourMoney,aFiveMoney);

				if(type==4){
					bookbinding=aFourMoney
				}else if(type==5){
					bookbinding=aFiveMoney
				}
				if(Math.floor(page/220)==0){
					bookbinding=bookbinding*Volumes;
				}
				else if(page%220<=5 && Math.floor(page/220)>0){ //220-225
					bookbinding=bookbinding*(Volumes-1);
				}
				else if(page%220>5 && Math.floor(page/220)>0){ //>225
					bookbinding=bookbinding*Volumes;
				}

				//總價=（页数*纸张价格+封面价格）*数量
				if(pages<60 && !relation){
					pages=60;
				}else if(pages<60 && relation==1){
                    pages=60;
				}
				else if(pages<120 && relation==2){
                    pages=120;
				}else if(pages<120 && relation==3){
                    pages=120;
				}
				total=((pages*multiple+bookbinding)*goodsNums).toFixed(2)
            if(relation==1){
                var realtotalmoney=0;
                if(pages<=60){
                    realtotalmoney=(99).toFixed(2)
                }else if(pages>220){
                    realtotalmoney=(99+(pages-60)*3.2+8*(Volumes-1)).toFixed(2)
                }else{
                    realtotalmoney=(99+(pages-60)*3.2).toFixed(2)
                }
                $('#realtotalmoney').val(realtotalmoney)

                // total=realtotalmoney;
            }else if(relation==2){
                if(pages<=120){
                    realtotalmoney=(199).toFixed(2)
                }else if(pages>220){
                    realtotalmoney=(199+(pages-120)*3.2+18*(Volumes-1)).toFixed(2)
                }else{
                    realtotalmoney=(199+(pages-120)*3.2).toFixed(2)
                }
                $('#realtotalmoney').val(realtotalmoney)
			}else if(relation==3){
                if(pages<=120){
                    realtotalmoney=(299).toFixed(2)
                }else if(pages>220){
                    realtotalmoney=(299+(pages-120)*5.8+18*(Volumes-1)).toFixed(2)
                }else{
                    realtotalmoney=(299+(pages-120)*5.8).toFixed(2)
                }
                $('#realtotalmoney').val(realtotalmoney)
			}


			if(relation==1){
                total=216;
			}

			$('#totalMoney').text(total)
		}
		//计算重量
//		var weight=1000;

		//备用
		function dd(){
			console.log(1111);
			$('.img2').attr('src','http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/Rectangle 19.png');
			$(this).siblings().attr('src','http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/Group 15.png');
			$(this).addClass('cur');
			var weight=computeWeight();
			var type=$(this).attr('data-id');
			var kd=Number($(this).attr('data-price'));
			var add=Number($(this).attr('data-add'));
			var money=0;
			$('#wuliuType').val(type);
			if(weight>1000){
				money=kd+((weight/1000)-1)*add;
			}else{
				money=kd;
			}
			$('#kd').text(money.toFixed(2))
			realMoney();
		}
		
	
		//总价
		function realMoney(){
			var page=Number($('#bookPage').text());//页数
//			var page=$('#page').val();//
			var kd=Number($('#kd').val());//快递费
			var goodscount=Number($('#goodscount').val());//数量
			var real=Number( $('#real').val());//纸张的价格
			var aFourMoney=Number( $('#aFourMoney').val());//封面的价格
			if(page<60){
				var gross=goodscount*(60*real+aFourMoney)+kd;
			}else if(page>160){
				var covervount=Math.ceil(page/160)
				var gross=goodscount*(page*real+aFourMoney*covervount)+kd;
			}else{
				var gross=goodscount*(page*real+aFourMoney)+kd;
			}			
			 gross=gross.toFixed(2);
			 $('.totalMoney').text(gross);
			  $('.refer_span').text(gross);
			
		}
			//优惠券事件
			$(function(){
				var iscoupon=$('#iscoupon').val();
			  if(iscoupon==""){
			  	$('#pre-div').css('display','block');
			  	$('#preferential').css('display','none');
			  }else{
			  		$('#pre-div').css('display','none');
			  	$('#preferential').css('display','block');
			  }
			})

		
		var  present=$('.input3').click(function(){
				$('.img3').attr('src', 'http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/Group 15.png');
				$('.img4').attr('src', 'http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/Rectangle 19.png');
		     	$('.pre-span').text('￥-10:00').css('margin-left','1.4rem');
		        $('.input3').val(1);
		     	var real=$('#real').text();
		     	real=(real-10).toFixed(2);
		     	$('#real').text(real)
			})
	
       
      var present1= $('.input4').click(function(){
				$('.img3').attr('src', 'http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/Rectangle 19.png');
				$('.img4').attr('src', 'http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/Group 15.png');
				$('.pre-span').text('￥ 0:00').css('margin-left','1.75rem');		
//				var present=Present();
				var iscoupon=$('.input3').val()
				if(iscoupon==1){
				var real=$('#real').text();
		     	real=(Number(real)+10).toFixed(2);
		     	$('#real').text(real)
				}
        })

		//照片数特殊算法
		function specialCountMoney(){
			var page=Number($('#bookPage').text());//页数
			var type=Number($('#paperType').val());//纸张类型
			var aFourMoney=Number($('#aFourMoney').val());//a4价格
			var aFiveMoney=Number($('#aFiveMoney').val());//a5价格
			var goodsNums=Number($('#goodscount').val());//数量
			var total=0;
			//多与40页则新成一本书或者回去删照片
			if(page>70){
				alert('删照片')
			}
			var Volumes=Math.ceil(page/70);//一本成书数

			var bookbinding=0
			if(type==4){
				bookbinding=aFourMoney
			}else{
				bookbinding=aFiveMoney
			}
			total=bookbinding*Volumes*goodsNums;
		
		
	    $('#totalMoney').text(total)
		}
		



	//书本信息
	function head(){
		var userId = sessionStorage.getItem("userId");
		var pbId = sessionStorage.getItem("pbId");
		  $.ajax({
		    type:"POST",
		    url:"http://www.youyiku-yishu.cn/WebApp/AppOrders/buylist",
		    data:{userId:userId,photoBookId:pbId},
		    dataType:"json",
		     beforeSend: function (XMLHttpRequest) {
		         		XMLHttpRequest.setRequestHeader("DEVICEINFO", "JxRaZezavm3HXM3d9pWnYiqqQC1SJbsU");
		       }
		   }).then(data=>{			
	     		var goods=data.goods;
   				var cover=data.cover;
   				var personimg=data.personimg;
   				var shape=data.shape;
   				var Css=data.css;
   				var img=data.img;
              	var relation=data.relation;
              	var papersize=data.papersize;
              	var bookbinding=data.bookbinding;
             	var wuliu=data.wuLiu;
				var booksmes='';
				var page=goods.page;			
              	booksmes+='<div class="book_main">';
              	booksmes+='<div class="book_img">';
					if(goods.bookType==4){
                        booksmes+='<div class="photo_book">';
							if(personimg){
                                booksmes+='<div class="imgbox'+cover.id+'" style="background-color: #fff;"><img src="http://www.youyiku-yishu.cn/'+personimg+'" class="shape_'+shape+'"></div>';
							}else{
                                booksmes+='<div class="imgbox'+cover.id+'"></div>';
							}
						booksmes+='<img src="http://www.youyiku-yishu.cn/'+cover.image+'" class="img">';
						booksmes+='<div class="mian1_header '+cover.css1+'">'+goods.bookname+'</div>';
                        booksmes+='<div class="mian1_bottom '+cover.css2+'">'+cover.title+'</div>';
                        booksmes+='</div>';
							}
						else{
                        booksmes+='<div class="center">';
                        booksmes+='<div class="'+Css.css1+'">';
                        booksmes+='<div class="textname">';
                        booksmes+='<div style="text-align:right;font-family: fzxsjt;color: #3C3C3C;font-weight:normal;font-size:0.213333rem;">'+cover.bookname+'</div>';
                        booksmes+='<div style="text-align:right;color:#3C3C3C;font-family: fzxsjt;">'+cover.author+'·作品</div>';
                        booksmes+='<p >'+cover.author+'·作品</p>-->';
                        booksmes+='</div>';
                        booksmes+='</div>';
						if(img.image.toString().indexof('pload')>0){
						booksmes+='<div class="'+Ccss.css2+'">';
						booksmes+='<div class="bookimg">';
						booksmes+='<img src="http://www.youyiku-yishu.cn/'+img.image+'"  class="shape_'+img.shape+'" alt="2">';
						booksmes+='</div>';
						booksmes+='</div>';
						}else{
						booksmes+='<div class="'+Css.css2+'">';
						booksmes+='<div class="bookimg">';
						booksmes+='<img src="http://www.youyiku-yishu.cn/'+img.image+'" class="img absolute alt" alt="2">';
						booksmes+='</div>';
						booksmes+='</div>';
						}
						booksmes+='<div id="booktext">优忆库-出品</div>';
                        booksmes+='</div>;'
						}

					    booksmes+='</div>';
					    booksmes+='<input type="hidden" value="'+goods.bookType+'" id="bookType">';
					    booksmes+='<div class="book_text">';
//					    booksmes+='<div class="bookname">'+cover.author+'</div>';
					    booksmes+='<div class="style">';
						if(goods.bookType==1){
                            booksmes+='微信书';
                        }else if(goods.bookType==2){
                            booksmes+='微博书';
                        }else if(goods.bookType==3){
                            booksmes+='qq空间书';
                        }else if(goods.bookType==4){
                            booksmes+='照片书';
                        }
              			booksmes+='</div>';
						if(goods.bookType==4){
                            booksmes+='<p class="shisi" style="margin: 0;">书名：&nbsp;'+goods.bookname+'</p>';
                        }else{
                            booksmes+='<p class="shisi" style="margin:0;">书名：&nbsp;'+cover.bookName+'</p>';
                        }

						booksmes+='<p class="shisi">作者：&nbsp;'+cover.author+'</p>';
						
						booksmes+='<p class="shisi">页码：<span id="bookPage">'+page+'</span></p>';
						

						booksmes+='<div class="blueColor">';

						booksmes+='<div class="blueZi">';
						if(goods.page>220){
                            booksmes+='由于你的忆书已超过220页<br>系统免费为你平均分(1)(2)册<br>';
						}else if(goods.page<60){
                            booksmes+='你的页数没有达到最低书本页数60页，<br>';
                            booksmes+='系统默认为你填补空白页，<br>';
                            booksmes+='或返回编辑增添内容';
                        }
						if(relation ==1 && goods.page>60){
                           booksmes+='超过60页部分需要补差价<br><br>或返回编辑删减内容至60页<br>';
							}else if(relation==2 && goods.page>120){
                            booksmes+='超过120页部分需补差价,（封面无优惠）<br>或返回编辑删减内容至120页<br>';
							}

						  booksmes+='</div>';
						  booksmes+='</div>';

						  booksmes+='</div>';
						  booksmes+='<input type="hidden" id="goodsId" value="'+goods.goodsId+'">';
						   booksmes+='<input type="hidden" id="page" value="'+goods.page+'">';
						  booksmes+='<input type="hidden" id="relation" value="'+relation+'">';
						  booksmes+='</div>';
						  $('.Book').html(booksmes);

				  var orderDetails='';
				  orderDetails+='<div class="numberBot" id="aa">';
				  orderDetails+='<a>购买数量</a>';
				  orderDetails+='<img src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/index/app/my/dingdan_2.png" class="numberBot_img" onclick="javascript:changeBookNum(1);">';
				  orderDetails+='<input type="number" value="1" name="" class="numberInput" maxlength="3" id="goodscount" disabled="true">';
				  orderDetails+='<img src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/index/app/my/dingdan_1.png"  class="numberBot_img1" onclick="javascript:changeBookNum(2);">';
				  orderDetails+='<b></b>';
				  orderDetails+='</div>';
				  orderDetails+='<div class="printingMain">';
				  orderDetails+='<span class="span1">标配用惠普indigo数码七色超高清印刷</span>';
				  orderDetails+='</div>';
				  orderDetails+='<div class="numberTop" onclick="numberTop()">';
				  orderDetails+='<img src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/my_bookshelf_icon_left_nor.png">';
				  orderDetails+='<span class="span">尺寸纸张类别</span>';
				  orderDetails+='<a class="CupCake">默认：A5文艺纸</a>';
				  orderDetails+='</div>';				 
				  orderDetails+='<div class="binding">';				  
				  orderDetails+='<div class="numberTop" onclick="numberTop1()">';
 				  orderDetails+='<img src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/my_bookshelf_icon_left_nor.png">';
				  orderDetails+='<span class="span">书籍装帧</span>';
				   orderDetails+='<a class="skin">默认：软皮经济装</a>';
				  orderDetails+='</div>';
				  orderDetails+='</div>';				  
				  orderDetails+='<div class="numberTop" onclick="numberTop2()">';
 				  orderDetails+='<img src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/my_bookshelf_icon_left_nor.png">';
				  orderDetails+='<span class="span">物流选择</span>';
				  orderDetails+='<b class="expressage">默认：韵达 免邮</b>';
				  orderDetails+='</div>';
				  
				  orderDetails+='<div class="comments" onclick="comments()">';
				  orderDetails+='<span>买家留言：</span>';
				  orderDetails+='<input type="text" name="" id="orderRemarks" value=""placeholder="说出你内心的小纠结，我们尽最大的能力满足你呢～"/>';
				  orderDetails+='</div>';
				   orderDetails+='<div class="price">';
				  orderDetails+='<div class="price_div">共';
				  orderDetails+='<b class="quantity">1</b>件商品';
				  orderDetails+='</div>';
				   orderDetails+='<div class="finally">小计：';
                  orderDetails+='<div class="finally_div"> ￥';
                   orderDetails+='<span class="totalMoney"></span>';
				  orderDetails+='</div>';			  
				  orderDetails+='</div>';
				  orderDetails+='</div>';		  
				  orderDetails+='</div>';				 
				 orderDetails+='<div class="radio">';
				  for(var i=0;i<papersize.length;i++){
					  orderDetails+='<div class="numberTop top top'+i+'" onclick="paper('+i+')">';
					  if(papersize[i].psId==1){
					  }else{
					  }

					  orderDetails+='<span class="span span_top">'+papersize[i].psName+'</span>';

						if(papersize[i].psId==1){
							orderDetails+='<span class="smp_1">(推荐)</span>';
						}


					  orderDetails+='<span class="smb">￥'+papersize[i].multiple+'</span>';
 					 orderDetails+='<img class="imgn imgn'+i+'" src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/index/app/my/yuan_1.png">';
					 orderDetails+=' </div>';
				  }
				  orderDetails+='<div class="radio_no" onclick="radio_no()">确定</div>';
				  orderDetails+=' </div>';
				  orderDetails+='<div class="logistics">';
				  orderDetails+='<div class="delivery" onclick="logistics(0)">';
				  orderDetails+='韵达快递';
				  orderDetails+='<span>(包邮，新疆、西藏、内蒙地区不包)</span>';
				  orderDetails+='<img class="delivery_img0" src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/index/app/my/yuan_1.png">';
				  orderDetails+='</div>';
				  orderDetails+='<div class="delivery" onclick="logistics(1)">';
				  orderDetails+='顺丰快递';
				  orderDetails+='<span>(加收12元邮费)</span>';
				  orderDetails+='<img class="delivery_img1" src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/index/app/my/yuan_1.png">';
				  orderDetails+='</div>'
				  orderDetails+='<div class="radio_no" onclick="radio_no2()">确定</div>';	
				  orderDetails+='</div>';
				  orderDetails+='<div class="size">';				  
				  orderDetails+='<div class="radio_1">';
				  orderDetails+='<div class="size_1">';
				  orderDetails+='实物展示';
				  orderDetails+=' <span>(点击查看)<span>';
				  orderDetails+=' </div>';
				  for(var i=0;i<bookbinding.length;i++){
					  orderDetails+='<div class="numberTop1 top numberTop_'+i+'" onclick="bookbinding('+i+')">';
						  if(bookbinding[i].bbdId==1){
						  }else{

						  }
					  orderDetails+='<span class="span span_top span_top'+i+'">'+bookbinding[i].bbdName+'</span>';
					  orderDetails+='<img class="imgn_'+i+'" src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/index/app/my/yuan_1.png">';
					  orderDetails+='</div>';
				  }
				  orderDetails+='<div class="radio_no" onclick="radio_no1()">确定</div>';				
				  orderDetails+='</div>';
				  orderDetails+='</div>';
				 $('.order_main').html(orderDetails);
				 
		 realMoney();
	 });





	}
//添加收货地址
$('.nothave>span').click(function (){
	location.href = 'address1.html';
})
//确定订单
function addOrder(){
			var userId = sessionStorage.getItem("userId");
			var pbId = sessionStorage.getItem("pbId");
			var bookType = $("#bookType").val();
			goodsId=$('#goodsId').val()
			page=Number($('#bookPage').text());//页数
			paper=Number($('#paper').val());//纸张材质
			var relation=$('#relation').val();
			 bookbinding=$('#bookbinding').val();
			goodsNums=Number($('#goodscount').val());//数量
			total=Number($('.refer_span').text());//价格
			wuliuType=$('#wuliuType').val();//快递类型
			kd=Number($('#kd').val());//快递
			userName=$('.name').text();//收件人姓名
			phone=$('.phone').text()//联系电话
			areaId1=$('#areaId1').val();
			areaId2=$('#areaId2').val();;
			areaId3=$('#areaId3').val();;
			address=$('.address').text()//详细地址
			orderRemarks=$('#orderRemarks').val()//留言
		  if(phone==''|| areaId1==''|| areaId2==''){
			warn1();
		}else{
			
		
			      $.ajax({
							type:"POST",
							url:"http://www.youyiku-yishu.cn/WebApp/AppOrders/addBookOrder",
							data:{
								userId:userId,
								goodsId:goodsId,
								total:total,
								kd:kd,
								wuliuType:wuliuType,
								page:page,
								paper:paper,
								userName:userName,
								phone:phone,
								areaId1:areaId1,
								areaId2:areaId2,
								areaId3:areaId3,
								address:address,
								orderRemarks:orderRemarks,
								goodsNums:goodsNums,
								bookbinding:bookbinding
							},
						    dataType:"json",
							beforeSend: function (XMLHttpRequest) {
							XMLHttpRequest.setRequestHeader("DEVICEINFO", "JxRaZezavm3HXM3d9pWnYiqqQC1SJbsU");
													       }
							}).then(data=>{
								console.log(data)
							var orderId=data.orderId;
							sessionStorage.setItem("orderId", orderId);
//							location.href = "./sureOrder.html";
							$('.payoff').css('display','block');
							
									 })
							}
			
		}
$('.order_main').click(function(){
	$('.payoff').css('display','none');
})
$('.Book').click(function(){
	$('.payoff').css('display','none');
})
$('.information').click(function(){
	$('.payoff').css('display','none');
})
$('.revert').click(function(){
	location.href = "../index.html";
})
function warn1(){
	 $('.warn').css('display','block');
	setTimeout(function(){
		 $('.warn').css('display','none')
		 },1500);
	
}
